//函数防抖
export function DeBounce(func,wait,immediate){
    let timer;

    return function(){
        let context=this;
        let args=arguments;
        if(timer){
            clearTimeout(timer);
        }
        
        if(immediate){
            let callnow=!timer;

            timer=setTimeout(function(){
                timer=false;
            },wait)

            if(callnow){
                func.apply(context,args);
            } 
        }else{
            timer=setTimeout(function(){
                func.apply(context,args);
            },wait)
        }
    }
}